package com.example.yaxin.controller;

import com.example.yaxin.entity.Weather;
import com.example.yaxin.service.impl.ScheduleService;
import com.example.yaxin.service.impl.WeatherService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/mail")
public class WeatherController {
    @Resource
    private WeatherService weatherService;
    @Resource
    private ScheduleService scheduleService;

    @GetMapping("/send")
    public String sendWeatherReport() {
        try {
            Weather weather = weatherService.queryWeather("石家庄");
            System.out.println(weather);
            scheduleService.send(weather);
        } catch (Exception e) {
            e.printStackTrace();
            return "发送失败";
        }
        return "发送成功";
    }
}
